#pragma once

#include <vector>
#include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
#include "llvm/ExecutionEngine/JIT.h"

using namespace llvm;

void CopyInstructions(BasicBlock *BB, std::vector<Instruction*> &Instructions);
void CopyInstructions(Function *F, std::vector<Instruction*> &Instructions);
void CopyInstructions(Module *M, std::vector<Instruction*> &Instructions);
int isCached(void *addr);

template<class T, class U>
inline T mighty_cast(U u)
{
        union { T t; U u; } axe;
        axe.u = u;
        return axe.t;
}

template<int N>
class Arr
{
public:
	Arr()
	{
		for (int i = 0; i < N; ++i)
			data[i] = 0;
	}

	int operator[] (int n) { return data[n]; }
	void Inc(int n) { ++data[n]; }
private:
	int data[N];
};
